<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>for</title>
</head>
<body>
    <script>
    //1-n质数
        // qiuzhishu(100);
        function qiuzhishu(num){
            var arr=[];
            for(var i=1;i<=num;i++)
            {   
                var n=0;
                for(var j=1;j<=i;j++)
                {
                    if(i%j==0)
                    {
                        n++;
                    }
                }
                if(n==2)
                {
                    arr.push(i);
                }
            }
            document.write(arr);
        }

    //乘法表
        // chengfabiao();
        function chengfabiao(){
            for(var i=1;i<=9;i++)
            {
                for(var j=1;j<=i;j++)
                {
                    var n=i*j;
                    if(i*j<10)
                    {
                        n=i*j+'&nbsp;';
                    }
                    document.write(j+'X'+i+'='+n+'&nbsp;');
                }
                document.write('<br>')
            }
        }
    
    //金字塔
        // jinzita(100);
        function jinzita(num){
            for(var i=1; i<=num;i++)
            {
                document.write('<hr style="width:'+i*1+'%;">');
            }
        }
        

    //数组
    //排序
    var arr=[7,9,2,4,6,8,1,3,8,1,85]
    arr.sort(function(a,b){return a-b;});
    var str=arr.join('');
    // console.log(str);
    console.log(str.replace('7','20'));
    console.log(arr);


    </script>
</body>
</html>